package com.woniuxy.carrental.mapper;


import com.woniuxy.carrental.entity.CCC;
import com.woniuxy.carrental.entity.Purchase;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

/**
 * 供应商车信息表  Supply_carMapper   Dao
 * @author xilei
 * @create 2021-09-22 下午 3:38
 */
@Mapper
public interface PurchaseMapper {
//    查所有车采购记录信息
    List<Purchase> findPurchase();
    //分页查采购记录信息
    List<Purchase> findPurchaseByPage(@Param("pageIndex") Integer pageIndex, @Param("pageSize") Integer pageSize);
    //分页查+按条件查采购记录信息
    List<Purchase> findPurchaseByPageByParam(@Param("purchase_id") Integer purchase_id,
                                                 @Param("purchase_date") Date purchase_date,
                                                 @Param("car_name") String car_name,
                                                 @Param("carpart_name") String carpart_name,
                                                 @Param("supplier_name") String supplier_name,
                                                 @Param("pageIndex") Integer pageIndex,
                                                 @Param("pageSize") Integer pageSize);

    //分页查+按条件查采购记录信息
    List<CCC> findPurchaseBy111();
    //删车辆关系信息
    void deletePurchase(String purchase_id);
    //增采购信息
    void insertPurchase(@Param("purchase_id") String purchase_id,@Param("purchase_date")  Date purchase_date,@Param("car_name") String car_name,@Param("carpart_name") String carpart_name,@Param("supplier_name") String supplier_name,@Param("car_count") Integer car_count,@Param("part_count") Integer part_count,@Param("part_allsprice") Integer part_allsprice,@Param("car_allsprice") Integer car_allsprice,@Param("wareingstatus") Boolean wareingstatus);

    //根据id查询表中数据
    @Select("select * from purchase where purchase_id=#{purchase_id}")
    Purchase selectPuByid(String purchase_id);

    //查询所有的可以入库的订单
    @Select("select * from purchase where wareingstatus=true")
    public List<Purchase> selectAllBytrue();

    //入库成功后将该条数据的状态由true改为false根据id更改
    @Update("update purchase set wareingstatus=false where purchase_id=#{purchase_id}")
    void updataByState(String purchase_id);
}
